package com.nulldev.util.web.URLUtils.internal.testing;

import java.net.URL;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.io.FastIO.FastIO;
import com.nulldev.util.web.URLUtils.URLUtils;
import com.nulldev.util.web.YouTubeExtractor.Qtraxtor.Qtraxtor;
import com.nulldev.util.web.YouTubeExtractor.Qtraxtor.Qtraxtor.FillMode;
import com.nulldev.util.web.YouTubeExtractor.Qtraxtor.Qtraxtor.SplitMode;
import com.nulldev.util.web.legacyURI.LegacyURIUtils;

public class URLQueryWithExtraCharsParserTest {

	@SuppressWarnings("deprecation")
	public static void main(String[] args) throws Exception {
		final String url = "/proxyAPI?rn=1&rbuf=0&val=A124E=&y=3";
		final URL u = new URL("http://127.0.0.1:8080" + url);
		{
			final long start = System.currentTimeMillis();
			JVM.println(LegacyURIUtils.queryStringToMap(url));
			final long end = System.currentTimeMillis();
			JVM.println("[Legacy::queryStringToMap] " + (end - start) + "ms");
			FastIO.get().flush();
		}
//		{
//			final long start = System.currentTimeMillis();
//			JVM.println(URLUtils.splitQuery(u));
//			final long end = System.currentTimeMillis();
//			JVM.println("[URLUtils::splitQuery] " + (end - start) + "ms");
//			FastIO.get().flush();
//		}
		{
			final long start = System.currentTimeMillis();
			Qtraxtor.get(url, SplitMode.STANDARD, FillMode.FILL_INTO_SINGLE_SET);
			final long end = System.currentTimeMillis();
			JVM.println("[YTE::Qtraxtor] " + (end - start) + "ms");
			FastIO.get().flush();
		}
		try {
			final long s = System.currentTimeMillis();
			JVM.println(URLUtils.parseQuery(URLUtils.parseURL_NoAccel(url)));
			final long e = System.currentTimeMillis();
			JVM.println("[URLUtils::parseQuery]: " + (e - s) + " ms");
			FastIO.get().flush();
		} catch (Exception e) {
			JVM.errorln(e);
		}
		try {
			final long s = System.currentTimeMillis();
			JVM.println(URLUtils.parseQuery(URLUtils.parseURL(url)));
			final long e = System.currentTimeMillis();
			JVM.println("[URLUtils::parseQuery_ACCEL]: " + (e - s) + " ms");
			FastIO.get().flush();
		} catch (Exception e) {
			JVM.errorln(e);
		}
	}
}
